
package com.chessimo.printer;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;

import com.chessimo.config.Definitions;
import com.chessimo.main.Chess;
import com.chessimo.util.Utilities;


public class PrinterInfoPress implements MouseListener {
    

    private int frameWidth;
    private int frameHeight;
    private static JButton butBack = new JButton();
    private static JLabel mainBox = new JLabel();
    private static JLabel bottonBox = new JLabel();
    private static Border thickBorder;
    
    
    public PrinterInfoPress(int frameWidth, int frameHeight){
    	this.frameWidth = frameWidth;
    	this.frameHeight = frameHeight;
    }
    
	public void print() {
        printButBack("Back");
        printLogoChessimo("images/logochessimo.jpg");
        printLabCentral();
        printLabBotton();
    }
    
    
    public void printButBack(String txt) {
        
        int pos1 = 5; 
        int pos2 = 5;
        
        int butWidth = 140;
        int butHeight = 30;
        
        butBack = new JButton(txt);
        butBack.setBounds(pos1, pos2, butWidth, butHeight);
        butBack.setFont(Definitions.fontButtons);
        Chess.pPress.add(butBack, new Integer(25));
        butBack.addMouseListener(this);
        
    }
    
    public void printLogoChessimo(String logoImg) {
        
        int imgWidth = 270;
        int imgHeight = 91;
        
        int pos1 = (frameWidth / 2) - (imgWidth / 2);
        int pos2 = (frameHeight / 2) - (imgHeight / 2) - (frameHeight / 3);
        
        ImageIcon logo = new ImageIcon(logoImg);       
        
        JLabel labLogo = new JLabel(logo, 0);
        labLogo.setBounds(pos1, pos2, imgWidth, imgHeight);
        
        Chess.pPress.add(labLogo, new Integer(3)); 
        
        labLogo.addMouseListener(this);
        
    } 
    
       public void printLabCentral() {
        
        File file = new File("html/pt/press1.html");
        
        String content = Utilities.getContents(file);            
        
        int width = 500;
        int height = 200;
        
        int x = frameWidth / 2 - (width / 2) - 10;
        int y = frameHeight / 2 - (height / 2) - 100;
        
        
        mainBox.setOpaque(true);
        mainBox.setBackground(Definitions.bg1);
        thickBorder = new LineBorder(Definitions.border, 5);
        mainBox.setBorder(thickBorder);
        mainBox.setText("<html>" + content + "</html>");
        mainBox.setVerticalAlignment(JLabel.TOP);

        mainBox.setBounds(x, y, width, height);
        Chess.pPress.add(mainBox, new Integer(100));
 
        }
       
       
        public void printLabBotton() {
        
        File file = new File("html/pt/press2.html");
        
        String content = Utilities.getContents(file);            
        
        int width = 500;
        int height = 100;
        
        int x = frameWidth / 2 - (width / 2) - 10;
        int y = frameHeight / 2 - (height / 2) + 60;
        
        
        bottonBox.setOpaque(true);
        bottonBox.setBackground(Definitions.bg1);
        thickBorder = new LineBorder(Definitions.border, 3);
        bottonBox.setBorder(thickBorder);
        bottonBox.setText("<html>" + content + "</html>");
        bottonBox.setVerticalAlignment(JLabel.TOP);

        bottonBox.setBounds(x, y, width, height);
        Chess.pPress.add(bottonBox, new Integer(100));
 
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        if (e.getSource() == butBack) {
            try {
                Chess.selector(2);
            } catch (FileNotFoundException ex) {
                Logger.getLogger(PrinterInfoEloCalc.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(PrinterInfoEloCalc.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    @Override
    public void mousePressed(MouseEvent e) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseExited(MouseEvent e) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }
    
    
    









}
